import { reqGetUserAddress } from "@/api";
import { reqGetCommodityInfo } from "@/api";

let state = {
    address: [],
    commodityInfo: {}
};
let mutations = {
    GETUSERADDRESS(state, address) {
        state.address = address;
    },
    GETCOMMODITYINFO(state, commodityInfo) {
        state.commodityInfo = commodityInfo;
    }
};
let actions = {
    async getUserAddress({ commit }) {
        let result = await reqGetUserAddress();
        if (result.code == 200) {
            commit('GETUSERADDRESS', result.data);
        }
    },
    async getCommodityInfo({ commit }) {
        let result = await reqGetCommodityInfo();
        if (result.code == 200) {
            commit('GETCOMMODITYINFO', result.data);
        }
    }
};
let getters = {};

export default {
    state,
    mutations,
    actions,
    getters
}